package com.kexun.servlet.teacher;

import com.alibaba.fastjson.JSON;
import com.kexun.pojo.Teacher;
import com.kexun.pojo.User;
import com.kexun.service.TeaService;
import com.kexun.service.impl.TeaServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;

@WebServlet("/ServletupTea")
public class ServletupTea extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        //设置编码
        request.setCharacterEncoding("UTF-8");
        response.setContentType("text/html;charset=UTF-8");


        HttpSession session = request.getSession();
        Teacher tea = (Teacher) session.getAttribute("tea");
        int  teanum = tea.getTeaNum();
        String teaNum = String.valueOf(teanum);




     /*   System.out.println("begin this");
        String ss = request.getParameter("stuNum");//stuNum = 321
        System.out.println(ss);*/

        TeaService ts = new TeaServiceImpl();
        Teacher teacher = ts.findInfo(teaNum);
        String s = JSON.toJSONString(teacher);

        if(teacher!=null){
            response.getWriter().print(s);
        }




    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request, response);
    }
}
